package org.jogdiary2011.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2011-01-23 20:07:32")
/** */
public final class ExerciseResultMeta extends org.slim3.datastore.ModelMeta<org.jogdiary2011.model.ExerciseResult> {

    /** */
    public final org.slim3.datastore.StringAttributeMeta<org.jogdiary2011.model.ExerciseResult> description = new org.slim3.datastore.StringAttributeMeta<org.jogdiary2011.model.ExerciseResult>(this, "description", "description");

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.lang.Long> distance = new org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.lang.Long>(this, "distance", "distance", java.lang.Long.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.util.Date> exerciseDate = new org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.util.Date>(this, "exerciseDate", "exerciseDate", java.util.Date.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<org.jogdiary2011.model.ExerciseResult> menu = new org.slim3.datastore.StringAttributeMeta<org.jogdiary2011.model.ExerciseResult>(this, "menu", "menu");

    /** */
    public final org.slim3.datastore.ModelRefAttributeMeta<org.jogdiary2011.model.ExerciseResult, org.slim3.datastore.ModelRef<org.jogdiary2011.model.Person>, org.jogdiary2011.model.Person> personRef = new org.slim3.datastore.ModelRefAttributeMeta<org.jogdiary2011.model.ExerciseResult, org.slim3.datastore.ModelRef<org.jogdiary2011.model.Person>, org.jogdiary2011.model.Person>(this, "personRef", "personRef", org.slim3.datastore.ModelRef.class, org.jogdiary2011.model.Person.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.lang.Long> second = new org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.lang.Long>(this, "second", "second", java.lang.Long.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<org.jogdiary2011.model.ExerciseResult, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    /** */
    public final org.slim3.datastore.StringAttributeMeta<org.jogdiary2011.model.ExerciseResult> weather = new org.slim3.datastore.StringAttributeMeta<org.jogdiary2011.model.ExerciseResult>(this, "weather", "weather");

    private static final ExerciseResultMeta slim3_singleton = new ExerciseResultMeta();

    /**
     * @return the singleton
     */
    public static ExerciseResultMeta get() {
       return slim3_singleton;
    }

    /** */
    public ExerciseResultMeta() {
        super("ExerciseResult", org.jogdiary2011.model.ExerciseResult.class);
    }

    @Override
    public org.jogdiary2011.model.ExerciseResult entityToModel(com.google.appengine.api.datastore.Entity entity) {
        org.jogdiary2011.model.ExerciseResult model = new org.jogdiary2011.model.ExerciseResult();
        model.setDescription((java.lang.String) entity.getProperty("description"));
        model.setDistance((java.lang.Long) entity.getProperty("distance"));
        model.setExerciseDate((java.util.Date) entity.getProperty("exerciseDate"));
        model.setKey(entity.getKey());
        model.setMenu((java.lang.String) entity.getProperty("menu"));
        if (model.getPersonRef() == null) {
            throw new NullPointerException("The property(personRef) is null.");
        }
        model.getPersonRef().setKey((com.google.appengine.api.datastore.Key) entity.getProperty("personRef"));
        model.setSecond((java.lang.Long) entity.getProperty("second"));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        model.setWeather((java.lang.String) entity.getProperty("weather"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        org.jogdiary2011.model.ExerciseResult m = (org.jogdiary2011.model.ExerciseResult) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("description", m.getDescription());
        entity.setProperty("distance", m.getDistance());
        entity.setProperty("exerciseDate", m.getExerciseDate());
        entity.setProperty("menu", m.getMenu());
        if (m.getPersonRef() == null) {
            throw new NullPointerException("The property(personRef) must not be null.");
        }
        entity.setProperty("personRef", m.getPersonRef().getKey());
        entity.setProperty("second", m.getSecond());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("weather", m.getWeather());
        entity.setProperty("slim3.schemaVersion", 1);
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        org.jogdiary2011.model.ExerciseResult m = (org.jogdiary2011.model.ExerciseResult) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        org.jogdiary2011.model.ExerciseResult m = (org.jogdiary2011.model.ExerciseResult) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        org.jogdiary2011.model.ExerciseResult m = (org.jogdiary2011.model.ExerciseResult) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
        org.jogdiary2011.model.ExerciseResult m = (org.jogdiary2011.model.ExerciseResult) model;
        if (m.getPersonRef() == null) {
            throw new NullPointerException("The property(personRef) must not be null.");
        }
        m.getPersonRef().assignKeyIfNecessary(ds);
    }

    @Override
    protected void incrementVersion(Object model) {
        org.jogdiary2011.model.ExerciseResult m = (org.jogdiary2011.model.ExerciseResult) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        org.jogdiary2011.model.ExerciseResult m = (org.jogdiary2011.model.ExerciseResult) model;
        writer.beginObject();
        org.slim3.datastore.json.JsonCoder encoder = null;
        if(m.getDescription() != null){
            writer.setNextPropertyName("description");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getDescription());
        }
        if(m.getDistance() != null){
            writer.setNextPropertyName("distance");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getDistance());
        }
        if(m.getExerciseDate() != null){
            writer.setNextPropertyName("exerciseDate");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getExerciseDate());
        }
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getKey());
        }
        if(m.getMenu() != null){
            writer.setNextPropertyName("menu");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getMenu());
        }
        if(m.getPersonRef() != null && m.getPersonRef().getKey() != null){
            writer.setNextPropertyName("personRef");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getPersonRef(), maxDepth, currentDepth);
        }
        if(m.getSecond() != null){
            writer.setNextPropertyName("second");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getSecond());
        }
        if(m.getVersion() != null){
            writer.setNextPropertyName("version");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getVersion());
        }
        if(m.getWeather() != null){
            writer.setNextPropertyName("weather");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getWeather());
        }
        writer.endObject();
    }

    @Override
    public org.jogdiary2011.model.ExerciseResult jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        org.jogdiary2011.model.ExerciseResult m = new org.jogdiary2011.model.ExerciseResult();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.JsonCoder decoder = null;
        reader = rootReader.newObjectReader("description");
        decoder = new org.slim3.datastore.json.Default();
        m.setDescription(decoder.decode(reader, m.getDescription()));
        reader = rootReader.newObjectReader("distance");
        decoder = new org.slim3.datastore.json.Default();
        m.setDistance(decoder.decode(reader, m.getDistance()));
        reader = rootReader.newObjectReader("exerciseDate");
        decoder = new org.slim3.datastore.json.Default();
        m.setExerciseDate(decoder.decode(reader, m.getExerciseDate()));
        reader = rootReader.newObjectReader("key");
        decoder = new org.slim3.datastore.json.Default();
        m.setKey(decoder.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("menu");
        decoder = new org.slim3.datastore.json.Default();
        m.setMenu(decoder.decode(reader, m.getMenu()));
        reader = rootReader.newObjectReader("personRef");
        decoder = new org.slim3.datastore.json.Default();
        decoder.decode(reader, m.getPersonRef(), maxDepth, currentDepth);
        reader = rootReader.newObjectReader("second");
        decoder = new org.slim3.datastore.json.Default();
        m.setSecond(decoder.decode(reader, m.getSecond()));
        reader = rootReader.newObjectReader("version");
        decoder = new org.slim3.datastore.json.Default();
        m.setVersion(decoder.decode(reader, m.getVersion()));
        reader = rootReader.newObjectReader("weather");
        decoder = new org.slim3.datastore.json.Default();
        m.setWeather(decoder.decode(reader, m.getWeather()));
    return m;
}
}